﻿<%@ Control Language="C#" %>
<script runat="server">
    public int Conut = 1;
    private int cid = 0;
    private Boolean isShowHd = true;
    private Boolean isShowSmaillPic = false;
    private int interTime = 2500;
    private string effect = "topLoop";
    private string class_name = "slider";
    private Boolean hd_li_width_is_avg = true;

    /* 数据绑定 */
    protected void Page_Load(object sender, EventArgs e)
    {
        int Item_Lang = Utils.GetQueryString("lang", 1);
        Advertisement Ad = new Advertisement();
        /* 优先级绑定，缩略图模式的HD优先级最高，如果它启用了，其他HD标签停用 */
        if (IsShowSmaillPic)
            IsShowHd = false;
        Repeater_List.DataSource = Ad.Advertisement_List(Item_Lang, cid);
        Repeater_Number.DataSource = Repeater_List.DataSource;
        Repeater_PicList.DataSource = Repeater_List.DataSource;
        Repeater_List.DataBind();
        Repeater_Number.DataBind();
        Repeater_PicList.DataBind();
    }
    /// <summary>
    /// 当前栏目ID[column_id]
    /// </summary>
    public int Cid
    {
        get { return cid; }
        set { cid = value; }
    }
    /// <summary>
    /// 动画效果
    /// </summary>
    public string Effect
    {
        get { return effect; }
        set { effect = value; }
    }
    /// <summary>
    /// 是否显示数字控制器
    /// </summary>
    public Boolean IsShowHd
    {
        get { return isShowHd; }
        set { isShowHd = value; }
    }
    /// <summary>
    /// 是否显示缩略图
    /// </summary>
    public Boolean IsShowSmaillPic
    {
        get { return isShowSmaillPic; }
        set { isShowSmaillPic = value; }
    }
    /// <summary>
    /// 延迟时间，每一个广告图的呆在时间
    /// </summary>
    public int InterTime
    {
        get { return interTime; }
        set { interTime = value; }
    }
    /// <summary>
    /// 定义动画组件DIV的class值，默认值slider,如果赋值多个class 按空格分裂,第一值前面不用加点
    /// </summary>
    public string Class_Name
    {
        get { return class_name; }
        set { class_name = value; }
    }
    /// <summary>
    /// 控制器列表的每一项的宽度是否需要赋值平均宽度
    /// </summary>
    public Boolean Hd_Li_Width_Is_Avg
    {
        get { return hd_li_width_is_avg; }
        set { hd_li_width_is_avg = value; }
    }


</script>
<div class="<%=Class_Name %>">
    <div class="bd">
        <ul>
            <asp:Repeater runat="server" ID="Repeater_List">
                <ItemTemplate>
                    <li><a href="<%#Eval("Item_Url")%>" style=" background-image:url(../DataFile/Ad/<%#Eval("Create_Time","{0:yyyyMM}") %>/<%#Eval("Create_Time","{0:ddHHmmss}") %>.jpg)"></a></li>
                </ItemTemplate>
            </asp:Repeater>
        </ul>
    </div>
    <%if(IsShowHd){ %>
     <div class="hd hd_text">
        <ul>
            <asp:Repeater runat="server" ID="Repeater_Number">
                <ItemTemplate>
                    <li><%=Conut%><%Conut++; %></li>
                </ItemTemplate>
            </asp:Repeater>
        </ul>
    </div>
    <%} %>
    <%if (IsShowSmaillPic){ %>
     <div class="hd hd_pic_list">
        <ul>
            <asp:Repeater runat="server" ID="Repeater_PicList">
                <ItemTemplate>
                    <li><img src="../DataFile/Ad/<%#Eval("Create_Time","{0:yyyyMM}") %>/<%#Eval("Create_Time","{0:ddHHmmss}") %>_ssss.jpg" /></li>
                </ItemTemplate>
            </asp:Repeater>
        </ul>
    </div>
    <%} %>

    
    <!-- 自动分页 -->

    <div class="pnBtn prev">
        <span class="blackBg"></span>
        <a class="arrow" href="javascript:void(0)"></a>
    </div>
    <div class="pnBtn next">
        <span class="blackBg"></span>
        <a class="arrow" href="javascript:void(0)"></a>
    </div>

</div>
<script type="text/javascript">
    jQuery(".<%=Class_Name %>").slide({ mainCell: ".bd ul", autoPlay: true, effect: "<%=Effect%>",interTime:<%=InterTime%> });
    /* 计算控制器宽度 */
    var item_count = $(".slider .hd ul li").length;
    var newWidth = 100 / item_count;
    $(".slider div.hd_text ul li").css("width", newWidth + "%");
    
    $(".slider div.hd_pic_list").css("width", (item_count*120+item_count*10)+"px");

    
</script>
